home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / prntutil / dublpag4 / printer.s < prev    next >
Text File  |  1995-04-27  |  9KB  |  259 lines

  1. * Printer driver skeleton for use with Double-Page IV
  2. * Copyright 1990 Douglas N. Wheeler.  All Rights Reserved.
  3.  
  4. * NOTE: This module MUST be position-independent since no relocation is
  5. *    performed on it.
  6. *
  7. *    Also, the first instruction MUST be a BRA followed immediately
  8. *    by the longword 'DP40'.  RETURN should be at start+34.
  9.  
  10. *--------------------------------------------------------------------------
  11. * START OF REQUIRED DATA
  12.  
  13. entry:    bra    realstart        branch to real start location
  14.  
  15. magic:    dc.l    'DP40'            magic number, must be here!
  16. name:    dc.b    'Printer Skeleton 1.1'    20 character name of driver
  17.  
  18. * The return value is a 0 if the print was successful or a number from
  19. * 1 to 15 which indicates the type of error that occurred.  Double-Page
  20. * will use this number as an offset into the failure text array below and
  21. * use the text there for the error dialog presented to the user.  The
  22. * 'retry' list below specifies what retry action should be taken by
  23. * Double-Page IV for a given error.
  24.  
  25. return:    dc.w    0            return value (0=no error, NZ=error)
  26.  
  27. * These two values gets filled in by Double-Page IV before the driver is
  28. * called.  Their use is shown in the 'image_page' routine.
  29. layoutaddr:
  30.     dc.l    -1            address of page layout array
  31. fontaddr:
  32.     dc.l    -1            address of font bitmap
  33.  
  34. * These must be here, and they must be 0.
  35. rsrvd1:    dc.w    0,0,0,0            (reserved for future expansion)
  36. rsrvd2:    dc.w    0,0,0,0,0,0,0,0        (reserved for future expansion)
  37.  
  38. * This retry list and failure text list is from the SLM driver.
  39.  
  40. * Retry flag for each error.  0=continue with next page, 1=retry same page,
  41. *                             2=failure - can't continue.
  42. retry:    dc.b    2,1,0,1,0,0,1,1
  43.     dc.b    1,1,1,1,1,1,1,1
  44.  
  45. * Text for error messages (other errors will report an UNKNOWN ERROR)
  46. fail1:    dc.b    'INSUFFICIENT MEMORY '    text for Error 1
  47. fail2:    dc.b    '  GENERAL ERROR 2   '    text for Error 2
  48. fail3:    dc.b    '    TONER EMPTY     '    text for Error 3
  49. fail4:    dc.b    ' PRINTER NOT READY  '    text for Error 4
  50. fail5:    dc.b    '    OUT OF PAPER    '    text for Error 5
  51. fail6:    dc.b    '     DRUM EMPTY     '    text for Error 6
  52. fail7:    dc.b    '    PAPER JAMMED    '    text for Error 7
  53. fail8:    dc.b    '    PAPER JAMMED    '    text for Error 8
  54. fail9:    dc.b    '    PAPER JAMMED    '    text for Error 9
  55. fail10:    dc.b    '     COVER OPEN     '    text for Error 10
  56. fail11:    dc.b    '  GENERAL ERROR 11  '    text for Error 11
  57. fail12:    dc.b    '  GENERAL ERROR 12  '    text for Error 12
  58. fail13:    dc.b    '  GENERAL ERROR 13  '    text for Error 13
  59. fail14:    dc.b    '  GENERAL ERROR 14  '    text for Error 14
  60. fail15:    dc.b    '  GENERAL ERROR 15  '    text for Error 15
  61.  
  62. * END OF REQUIRED DATA
  63. *--------------------------------------------------------------------------
  64.  
  65. pageaddr:
  66.     dc.l    -1            address of page image
  67.     
  68. *--------------------------------------------------------------------------
  69.     
  70. realstart:
  71.     move.l    #954000,-(sp)        1 US-Letter sized page
  72.     move.w    #$48,-(sp)        Malloc()
  73.     trap    #1
  74.     addq.l    #6,sp
  75.     tst.l    d0
  76.     beq    memfail            Oops, Malloc failed
  77.  
  78.     lea    pageaddr(pc),a3        location of page layout array variable
  79.     move.l    d0,(a3)            save address of page buffer
  80.  
  81.     bsr    clear_page        clear page bit-map
  82.     bsr    image_page        create bit-map from layout array
  83.     bsr    print_page        branch to real page print routine
  84.  
  85.     lea    pageaddr(pc),a3        location of page layout array variable
  86.     move.l    (a3),-(sp)        location of page buffer to free
  87.     move.w    #$49,-(sp)        Mfree()
  88.     trap    #1
  89.     addq.l    #6,sp
  90.     
  91.     rts                all done    
  92.     
  93. memfail:
  94.     lea    return(pc),a3        location of return variable
  95.     move.w    #1,(a3)            insufficient memory error
  96.     rts
  97.  
  98. *--------------------------------------------------------------------------
  99.  
  100. clear_page:
  101.     lea    pageaddr(pc),a3        location of page image variable
  102.     movea.l    (a3),a0            get location of page image
  103.     move.l    #0,d2            put this in register for max speed
  104.     move.w    #100-1,d0
  105. .loop1:    move.w    #2385-1,d1        * 238500 longwords to clear
  106. .loop2:    move.l    d2,(a0)+
  107.     dbf    d1,.loop2
  108.     dbf    d0,.loop1
  109.     rts
  110.     
  111. *--------------------------------------------------------------------------
  112.  
  113. * The page layout array is an array of words, with each word representing
  114. * one character location on the page (a word is used since using overstrike
  115. * may result in 2 characters at a given location).
  116. *
  117. * The array is layed out such that the first word is the upper left character
  118. * on the printed SHEET (not a page on that sheet).  The characters then
  119. * proceed DOWN the page.  There are 75 columns (66 lines + borders + header +
  120. * extra paper margins).  Each column consists of 198 words (80 characters +
  121. * borders + margins).  Within each word, the low byte is the primary character
  122. * at the location and the upper byte contains an overstriked character.  If
  123. * the two characters are the same, the second should be offset slightly to
  124. * produce a bold effect.
  125.  
  126. image_page:
  127.     lea    layoutaddr(pc),a3    location of page layout array variable
  128.     movea.l    (a3),a0            get location of page layout array
  129.     lea    pageaddr(pc),a3        location of page image variable
  130.     movea.l    (a3),a1            get location of page image
  131.     lea    fontaddr(pc),a3        location of page font variable
  132.     movea.l    (a3),a2            get location of font
  133.  
  134.     move.w    #0,d0            line counter
  135. nextline:
  136.     movea.l    a1,a3            copy of current location in page image
  137.  
  138.     move.w    #0,d1            column counter
  139. nextcolumn:
  140.  
  141.     move.w    (a0)+,d2        next character to print
  142.     beq    skipchar
  143.  
  144. * We can now print overlapping characters.
  145. * Low byte is 1st char., high bytes is 2nd.
  146.     move.w    d2,d3            duplicate
  147.         
  148.     andi.w    #$00ff,d3        mask to 1st character
  149.     beq    skip1st
  150.     movea.l    a2,a4            copy of font pointer
  151.     lsl.w    #6,d3            times 64 (offset to character in font)
  152.     adda.w    d3,a4            add character offset
  153.  
  154.     move.l    (a4)+,(a3)        copy character bitmap to page image
  155.     move.l    (a4)+,300(a3)        16 longwords - unrolled for speed
  156.     move.l    (a4)+,600(a3)
  157.     move.l    (a4)+,900(a3)
  158.     move.l    (a4)+,1200(a3)
  159.     move.l    (a4)+,1500(a3)
  160.     move.l    (a4)+,1800(a3)
  161.     move.l    (a4)+,2100(a3)
  162.     move.l    (a4)+,2400(a3)
  163.     move.l    (a4)+,2700(a3)
  164.     move.l    (a4)+,3000(a3)
  165.     move.l    (a4)+,3300(a3)
  166.     move.l    (a4)+,3600(a3)
  167.     move.l    (a4)+,3900(a3)
  168.     move.l    (a4)+,4200(a3)
  169.     move.l    (a4)+,4500(a3)
  170.  
  171. skip1st:
  172.     move.w    d2,d3            duplicate
  173.     lsr.w    #8,d3            shift 2nd character into place
  174.     andi.w    #$00ff,d3        mask to 2nd character
  175.     beq    skip2nd            no 2nd char
  176.  
  177.     andi.w    #$00ff,d2        mask to 1st character (for comparison)
  178.     sub.w    d3,d2            cheap compare (NZ means .ne.)
  179.     
  180.     movea.l    a2,a4            copy of font pointer
  181.     lsl.w    #6,d3            times 64 (offset to character in font)
  182.     adda.w    d3,a4            add character offset
  183.  
  184.     tst.w    d2            overstrike bold?
  185.     beq    overstk            yes, offset by one scanline
  186.  
  187.     move.l    (a4)+,d4
  188.     or.l    d4,(a3)
  189. overstk:
  190.     move.l    (a4)+,d4
  191.     or.l    d4,300(a3)        16 longwords - unrolled for speed
  192.     move.l    (a4)+,d4
  193.     or.l    d4,600(a3)        16 longwords - unrolled for speed
  194.     move.l    (a4)+,d4
  195.     or.l    d4,900(a3)
  196.     move.l    (a4)+,d4
  197.     or.l    d4,1200(a3)        Note: 2nd character is offset by 1
  198.     move.l    (a4)+,d4
  199.     or.l    d4,1500(a3)        scanline if 1st and 2nd chars are
  200.     move.l    (a4)+,d4
  201.     or.l    d4,1800(a3)        the same (for overstrike bold)
  202.     move.l    (a4)+,d4
  203.     or.l    d4,2100(a3)
  204.     move.l    (a4)+,d4
  205.     or.l    d4,2400(a3)
  206.     move.l    (a4)+,d4
  207.     or.l    d4,2700(a3)
  208.     move.l    (a4)+,d4
  209.     or.l    d4,3000(a3)
  210.     move.l    (a4)+,d4
  211.     or.l    d4,3300(a3)
  212.     move.l    (a4)+,d4
  213.     or.l    d4,3600(a3)
  214.     move.l    (a4)+,d4
  215.     or.l    d4,3900(a3)
  216.     move.l    (a4)+,d4
  217.     or.l    d4,4200(a3)
  218.     move.l    (a4)+,d4
  219.     or.l    d4,4500(a3)
  220.  
  221.     cmp.b    d2,d3            overstrike bold?
  222.     bne    noverstk        no, we're done
  223.  
  224.     move.l    (a4)+,d4
  225.     or.l    d4,4800(a3)
  226. noverstk:
  227. skip2nd:
  228. skipchar:
  229.     adda.l    #4800,a3        next line in page image
  230.     addi.w    #1,d1
  231.     cmpi.w    #198,d1            past last line?
  232.     bne    nextcolumn        no
  233.  
  234.     adda.l    #4,a1            next column in page image
  235.     addi.w    #1,d0
  236.     cmpi.w    #75,d0            past last line?
  237.     bne    nextline        no
  238.  
  239.     rts
  240.  
  241. *--------------------------------------------------------------------------
  242.  
  243. print_page:
  244.  
  245. * The actual low-level print routine goes here, and is very device
  246. * dependent.
  247. *
  248. * This routine should take the 300 dpi bitmap create by 'image_page' and
  249. * send it to the printer.  It should also set the 'return' variable to
  250. * reflect the success or failure of the print.
  251. *
  252. * This code assumes that the driver will create one big page image and
  253. * print it all at once.  It is also possible with some printers to print
  254. * the page in bands.  This can be accomplished by modifying image_page
  255. * to print only a certain range of lines each time.  This has the advantage
  256. * of using a much smaller page buffer, but is more complicated to program.
  257.  
  258. *--------------------------------------------------------------------------
  259.